<template>
  <form-panel :ok-click="submitForm">
    <div class="margin-37 margin-top-63">
      <div class="edit-page-input">
        <el-form ref="elForm" :model="queryObj" :rules="rules" size="medium" label-width="150px" label-suffix="：">
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="设备名称" prop="field101">
                <el-input v-model="queryObj.field101" placeholder="请输入设备名称" clearable :style="{ width: '100%' }">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="设备编码" prop="field102">
                <el-input v-model="queryObj.field102" placeholder="请输入设备编码" clearable :style="{ width: '100%' }">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="设备MN号" prop="field103">
                <el-input v-model="queryObj.field103" placeholder="请输入设备MN号" clearable :style="{ width: '100%' }">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="设备型号" prop="field104">
                <el-input v-model="queryObj.field104" placeholder="请输入设备型号" clearable :style="{ width: '100%' }">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="设备品牌" prop="field105">
                <el-input v-model="queryObj.field105" placeholder="请输入设备品牌" clearable :style="{ width: '100%' }">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="生产厂商" prop="field106">
                <el-input v-model="queryObj.field106" placeholder="请输入生产厂商" clearable :style="{ width: '100%' }">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="生产厂商联系人" prop="field107">
                <el-input
                  v-model="queryObj.field107"
                  placeholder="请输入生产厂商联系人"
                  clearable
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="生产厂商联系电话" prop="field108">
                <el-input
                  v-model="queryObj.field108"
                  placeholder="请输入生产厂商联系电话"
                  clearable
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="运维商" prop="field109">
                <el-input v-model="queryObj.field109" placeholder="请输入运维商" clearable :style="{ width: '100%' }">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="运维联系人" prop="field110">
                <el-input
                  v-model="queryObj.field110"
                  placeholder="请输入运维联系人"
                  clearable
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="启用日期" prop="field111">
                <el-date-picker
                  v-model="queryObj.field111"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  :style="{ width: '100%' }"
                  placeholder="请输入启用日期"
                  clearable
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="设备状态" prop="field113">
                <el-radio-group v-model="queryObj.field113" size="medium">
                  <el-radio
                    v-for="(item, index) in field113Options"
                    :key="index"
                    :label="item.value"
                    :disabled="item.disabled"
                    >{{ item.label }}
                  </el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="15">
            <el-col :span="24">
              <el-form-item label="备注" prop="field115">
                <el-input
                  v-model="queryObj.field115"
                  type="textarea"
                  placeholder="请输入备注"
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
  </form-panel>
</template>

<script>
export default {
  name: 'EquipmentInput',
  data() {
    return {
      queryObj: {
        field101: undefined,
        field102: undefined,
        field103: undefined,
        field104: undefined,
        field105: undefined,
        field106: undefined,
        field107: undefined,
        field108: undefined,
        field109: undefined,
        field110: undefined,
        field111: undefined,
        field113: 2,
        field115: undefined
      },
      rules: {
        field101: [
          {
            required: true,
            message: '请输入设备名称',
            trigger: 'blur'
          }
        ],
        field102: [
          {
            required: true,
            message: '请输入设备编码',
            trigger: 'blur'
          }
        ],
        field103: [
          {
            required: true,
            message: '请输入设备MN号',
            trigger: 'blur'
          }
        ],
        field104: [
          {
            required: true,
            message: '请输入设备型号',
            trigger: 'blur'
          }
        ],
        field105: [
          {
            required: true,
            message: '请输入设备品牌',
            trigger: 'blur'
          }
        ],
        field106: [
          {
            required: true,
            message: '请输入生产厂商',
            trigger: 'blur'
          }
        ],
        field107: [
          {
            required: true,
            message: '请输入生产厂商联系人',
            trigger: 'blur'
          }
        ],
        field108: [
          {
            required: true,
            message: '请输入生产厂商联系电话',
            trigger: 'blur'
          }
        ],
        field109: [
          {
            required: true,
            message: '请输入运维商',
            trigger: 'blur'
          }
        ],
        field110: [
          {
            required: true,
            message: '请输入运维联系人',
            trigger: 'blur'
          }
        ],
        field111: [
          {
            required: true,
            message: '请输入启用日期',
            trigger: 'change'
          }
        ],
        field113: [
          {
            required: true,
            message: '设备状态不能为空',
            trigger: 'change'
          }
        ],
        field115: [
          {
            required: true,
            message: '请输入备注',
            trigger: 'blur'
          }
        ]
      },
      field113Options: [
        {
          label: '启用',
          value: 1
        },
        {
          label: '停用',
          value: 2
        }
      ]
    }
  },
  methods: {
    submitForm() {
      this.$refs.elForm.validate(valid => {
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm() {
      this.$refs.elForm.resetFields()
    }
  }
}
</script>

<style lang="scss" scoped>
@import '~@/assets/pages/index.scss';
</style>
